<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Vote
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 * @version    $Id: Category.php 2011-03-09 08:45:41Z idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Vote
 * @copyright  Copyright KEENONWEB LLC
 * @license    http://www.keenonweb.com/
 */

class Vote_Model_Category extends Core_Model_Item_Abstract {
	
	public function getTable() {
		if (is_null ( $this->_table )) {
			$this->_table = Engine_Api::_ ()->getDbtable ( 'categories', 'vote' );
		}
		
		return $this->_table;
	}
	
	public function getUsedCount() {
		$table = Engine_Api::_ ()->getDbTable ( 'challenges', 'vote' );
		$rName = $table->info ( 'name' );
		$select = $table->select ()->from ( $rName )->where ( $rName . '.category_id = ?', $this->category_id );
		$row = $table->fetchAll ( $select );
		$total = count ( $row );
		
		return $total;
	}

}